﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBUtil.FastEntity.Annotations
{
    /// <summary>
    /// 拒绝映射操作
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class MapDenyOperateAttribute : Attribute
    {
        /// <summary>
        /// 拒绝映射操作的类型
        /// </summary>
        public MapDenyOperateType Type { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="type"></param>
        public MapDenyOperateAttribute(MapDenyOperateType type)
        {
            Type = type;
        }
    }

    /// <summary>
    /// 拒绝映射写入操作,包含:Insert/Update/Delete
    /// </summary>
    public class MapDenyWriteAttribute : MapDenyOperateAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MapDenyWriteAttribute() : base(MapDenyOperateType.Insert | MapDenyOperateType.Update) { }
    }

    /// <summary>
    /// 拒绝映射所有操作,包含:Select/Insert/Update/Delete
    /// </summary>
    public class MapDenyAllAttribute : MapDenyOperateAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public MapDenyAllAttribute() : base(MapDenyOperateType.Insert | MapDenyOperateType.Delete | MapDenyOperateType.Update | MapDenyOperateType.Select) { }
    }

    /// <summary>
    /// 拒绝映射的操作类型
    /// </summary>
    [Flags]
    public enum MapDenyOperateType
    {
        /// <summary>
        /// 空
        /// </summary>
        None = 1,
        /// <summary>
        /// 拒绝映射Insert
        /// </summary>
        Insert = 2,
        /// <summary>
        /// 拒绝映射Update
        /// </summary>
        Update = 4,
        /// <summary>
        /// 拒绝映射Delete
        /// </summary>
        Delete = 8,
        /// <summary>
        /// 拒绝映射Select
        /// </summary>
        Select = 16
    }
}
